<!-- BEGIN PAGE HEADER-->
<?php $this->load->view('partials/breadcrumb.tpl',  Array('_NO_IOSS_NEW'=>'1'))?>
<!-- END PAGE HEADER-->
<style>
    th,td{
        text-align: center;
    }
    .o-img{
        width: 50px !important;
        height: auto !important;
        border-radius: 50%;
    }
    .o-name{
        margin-left: 5px;
    }
</style>
<!-- BEGIN PAGE CONTENT-->
<script type="text/javascript">
function defConfirm(){
	if(!confirm("确定已退还保证金吗？")){
		return false;
	}
	return true;
}
$(document).ready(function(){
	$("#reset").click(function(){
		$("select").val('');
		$("input[type='text']").val('');
	});
});
</script>
<div class="row">
	<div class="col-xs-12">
		<!-- Begin: life time stats -->
		<div class="portlet">
			<?= form_open('', Array('class' => 'form-inline', 'role' => 'form')) ?>
            <?= search_form_input('nick_name', filterValue('nick_name'), '用户昵称', 'class="form-control input-small"'); ?>
			<?= search_form_dropdown('status', array('' => '缴纳状态...')+MPromise::getPromiseState(), filterValue('status'), '缴纳状态', 'class="form-control input-small"'); ?>
            <div style="clear:both;height: 13px"></div>
			<?= search_form_input('promise_number_perpage', filterValue('user_auth_info_number_perpage'), '每页显示条数', 'class="form-control input-small"'); ?>
			<div class="input-group input-large date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
				<input type="text" class="form-control" name="promise_create_time_begin"
					   value="<?= filterValue('user_auth_info_create_time_begin') ?>" placeholder="创建起始时间" autoComplete="off">
				<span class="input-group-addon">to </span>
				<input type="text" class="form-control" name="promise_create_time_end"
					   value="<?= filterValue('user_auth_info_create_time_end') ?>" placeholder="创建结束时间" autoComplete="off">
			</div>
			<button type="button" class="btn default" id="reset">重置条件</button>
			<button type="submit" class="btn green about_search">搜索 <i class="fa fa-search"></i></button>
			<?= form_close() ?>
			<div class="portlet-body">
				<div class="row">
					<div class="col-xs-12">
						<div class="table-scrollable">
							<table class="table table-hover table-bordered table-striped">
								<thead>
								<tr>
									<th>ID</th>
									<th>用户信息</th>
									<th>保证金金额</th>
									<th>支付时间</th>
									<th>申请退还时间</th>
									<th>退还到账时间</th>
									<th>缴纳状态</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								<?php foreach ($list as $v) { ?>
								<tr>
									<td><?= $v->id ?></td>
									<td>
                                        <img class="o-img img-rounded" src="<?= $v->avatar ?>" alt="<?= $v->nick_name ?>">
                                        <span class="o-name"><?= $v->nick_name ?></span>
                                    </td>
									<td>￥<?= $v->amount ?></td>
									<td><?= $v->pay_time? date('Y-m-d H:i:s', $v->pay_time):'' ?></td>
									<td><?= $v->apply_time? date('Y-m-d H:i:s', $v->apply_time):'' ?></td>
									<td><?= $v->return_time? date('Y-m-d H:i:s', $v->return_time):'' ?></td>
									<td><?= MPromise::getPromiseState($v->status) ?></td>
                                    <td><?= date('Y-m-d H:i:s', $v->create_time) ?></td>
                                    <td>
                                        <?php if ($v->status == 1): ?>
                                        <a href="javascript:;" data-oid="<?= $v->id ?>" class="btn btn-sm purple confirm-return"><i class="fa fa-edit"></i> 确认退还</a>
                                    <?php endif; ?>
                                    </td>
								</tr>
								<?php } ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12 text-right">
						<?= $pagination ?>
					</div>
				</div>
			</div>
		</div>
		<!-- End: life time stats -->
	</div>
</div>


<!-- END PAGE CONTENT-->
<script type="text/javascript">
	$(document).ready(function () {
		$('.img-rounded').zoomify();
	});
    $(".confirm-return").click(function () {
        var oid = this.dataset.oid;
        if (defConfirm()){
            $.ajax({
                url: "<?= site_url('user/promise/return_confirm') ?>",
                method: "POST",
                data: {'oid': oid},
                dataType: "JSON",
                success: function (data) {
                    if (data.status){
                        toastr.success(data.msg,'成功');
                        setTimeout(function () {
                            location.reload()
                        },1000)
                    }else {
                        toastr.error(data.msg,'失败');
                    }
                }
            })
        }
    })
</script>
